<script setup lang="ts">
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
import "@/assets/styles/index.scss";
import { mountGoLoginPageFunc } from "@/config";
import { obj2Query } from "@/utils";
import { useAppStore, useUserStore } from "@/store";

onLaunch(() => {
  console.log("App Launch");

  // 必须要调用 第一时间获取缓存
  useUserStore();

  const appStore = useAppStore();

  appStore.consumeLaunchJustNow();

  mountGoLoginPageFunc((params) => {
    // #ifndef WEB
    uni.redirectTo({
      url: `/pages/login/index${obj2Query(params || {})}`,
    });
    // #endif

    // #ifdef WEB
    uni.showToast({
      title: "请先登录",
      icon: "none",
    });
    // #endif
  });
});
onShow(() => {
  console.log("App Show");
});
onHide(() => {
  console.log("App Hide");
});
</script>
